package cn.aylog.config;

import cn.aylog.controller.SomeServlet;
import cn.aylog.filter.SomeFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ServletConfiguration {

    /*手动注册Servlet Bean*/
    @Bean
    public ServletRegistrationBean<SomeServlet> getSomeServletBean() {
        return new ServletRegistrationBean<>(new SomeServlet(), "/some");
    }

//    可以配置多个哦
//    @Bean
//    public ServletRegistrationBean<SomeServlet> getSomeServletBean2() {
//        return new ServletRegistrationBean<>(new SomeServlet(), "/some");
//    }

    /*手动注册Filter Bean*/
    @Bean
    public FilterRegistrationBean<SomeFilter> getSomeFilter() {
        FilterRegistrationBean<SomeFilter> filter = new FilterRegistrationBean<>();
        filter.setFilter(new SomeFilter());
        filter.addUrlPatterns("/*");
        return filter;
    }


}
